package com.qs.worklog.util;

import java.io.InputStream;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.tomcat.jdbc.pool.DataSource;

public class ConnectionUtil {
	
	private static Connection conn;
	private static String url;
	private static String user;
	private static String password;
	private static String driver;
	static{
		Properties props = new Properties();
		
		try {
			ClassLoader c1 = ConnectionUtil.class.getClassLoader();
			InputStream is = c1.getResourceAsStream("com/qs/worklog/util/db.properties");
			props.load(is);
			driver = props.getProperty("driverClassName");
			url = props.getProperty("url");
			user = props.getProperty("username");
			password = props.getProperty("password");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
	
	public static Connection getConnection() throws SQLException{
		try {
			Class.forName(driver);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		conn = DriverManager.getConnection(url, user, password);
		return conn;
	}
}
